/**
 *
 * @author John Creecy
 */

package battlebarnapplet;

import java.awt.Image;
import java.awt.event.KeyEvent;

import javax.swing.ImageIcon;

public class Player {

	public static int direction;
	public static int shot;
	private int x;
	private int y;

	public Player() {
	}

	public int getX() {
		return x;
	}

	public int getY() {
		return y;
	}

	public int getDirection() {
		return direction;
	}

	public void keyPressed(KeyEvent e) {

		int key = e.getKeyCode();

		if (key == KeyEvent.VK_LEFT) {
			direction = 4;
		}

		if (key == KeyEvent.VK_RIGHT) {
			direction = 2;
		}

		if (key == KeyEvent.VK_UP) {
			direction = 1;
		}

		if (key == KeyEvent.VK_DOWN) {
			direction = 3;
		}

		if (key == KeyEvent.VK_SPACE) {
			shot = 1;
		}
	}

	public void keyReleased(KeyEvent e) {
		int key = e.getKeyCode();

		if (key == KeyEvent.VK_LEFT) {
			direction = 0;
		}

		if (key == KeyEvent.VK_RIGHT) {
			direction = 0;
		}

		if (key == KeyEvent.VK_UP) {
			direction = 0;
		}

		if (key == KeyEvent.VK_DOWN) {
			direction = 0;
		}

		if (key == KeyEvent.VK_SPACE) {
			shot = 0;
		}
	}
}
